#!/bin/sh
#
export INSTALL_DIR=$2
#
echo "PROCESSING POSTINSTALL"
cd ${INSTALL_DIR}/bin
\rm -f focus.app
\rm -f fLogBrowser.app
\rm -f fMrcConverter.app
\rm -f fViewer.app
ln -sf ../focus/focus.app ./
ln -sf ../fLogBrowser/fLogBrowser.app ./
ln -sf ../fMrcConverter/fMrcConverter.app ./
ln -sf ../fViewer/fViewer.app ./
#
chown -RP root:wheel ${INSTALL_DIR}   
chmod -R 777 ${INSTALL_DIR}/kernel
#
open /Applications
#
envfile=/etc/paths.d/focus.sh
if [ -e ${envfile} ]; then
    rm ${envfile}
fi
echo "# Added by FOCUS on `date`:" >> ${envfile}
echo "# (makes standalone programs and Python modules available)" >> ${envfile}
echo "export FOCUS_ROOT=${PREFIX}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/kernel/mrc/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/scripts/proc:\${PATH}" >> ${envfile}
echo "export PYTHONPATH=\${FOCUS_ROOT}/scripts/proc:\${PYTHONPATH}" >> ${envfile}
chmod 755 ${envfile}
#
exit 0
